import _ from 'lodash';
import React from 'react';
import ReactECharts, {EChartsReactProps, EChartsInstance, EChartsOption} from 'echarts-for-react';

interface BasicChartProps extends EChartsReactProps {
    loading?: boolean;
    getEchartsInstance?: Function;
}

export type {EChartsInstance, EChartsOption};

const BasicChart: React.FC<BasicChartProps> = (props) => {
    const {option, loading, getEchartsInstance = _.noop, ...restProps} = props;
    return (
        <ReactECharts
            ref={(e) => getEchartsInstance(e)}
            lazyUpdate
            notMerge
            showLoading={loading}
            option={option}
            {...restProps}
        />
    );
};

export default BasicChart;
